package framework.editor;


import framework.data.GrupoQuarto;
import framework.panes.Editor;
import framework.panes.Editor;
import framework.panes.EditorPane;
import framework.panes.EditorPane;
import java.awt.Frame;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GrupoQuartoPane.java
 *
 * Created on Jun 9, 2011, 4:49:36 PM
 */
/**
 *
 * @author usuario
 */
public class GrupoQuartoEditor extends EditorPane 
{
    private GrupoQuarto grupoquarto;

    /**
     * 
     * @param Parent
     * @param grupo quarto
     * @return 
     */
    public static boolean edit( Frame parent, GrupoQuarto grupoquarto )
    {
        GrupoQuartoEditor pane = new GrupoQuartoEditor();
        
        pane.setGrupoQuarto( grupoquarto );
        
        return Editor.edit( parent, pane, "Cadastro de Grupo de Quartos" );
    }

    /** Creates new form GrupoQuartoPane */
    public GrupoQuartoEditor()
    {
        initComponents();
    }

    /**
     * 
     * @param p 
     */
    private void setGrupoQuarto( GrupoQuarto g )
    {
        this.grupoquarto = g;
        preencherCampos();
    }
    
    /**
     * 
     */
    private void preencherCampos()
    {
        tfCodigo.setText( String.valueOf( grupoquarto.getCodigo() ) );
        tfNome.setText( grupoquarto.getNome() );
        taDescricao.setText( grupoquarto.getDescricao() );
    }
    
    /**
     * 
     */
    @Override
    public void accept()
    {
        grupoquarto.setCodigo( Integer.parseInt( tfCodigo.getText() ) );
        grupoquarto.setNome( tfNome.getText() );
        grupoquarto.setDescricao( taDescricao.getText() );
    }

    @Override
    public String validateInput()
    {
        return "";
    }    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        tfCodigo = new javax.swing.JTextField();
        tfNome = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        taDescricao = new javax.swing.JTextArea();

        setLayout(new java.awt.GridBagLayout());

        jLabel1.setText("Grupo");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(15, 15, 5, 5);
        add(jLabel1, gridBagConstraints);

        jLabel2.setText("Descricao");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 15, 15, 5);
        add(jLabel2, gridBagConstraints);

        jPanel4.setLayout(new java.awt.GridBagLayout());

        tfCodigo.setEnabled(false);
        tfCodigo.setFocusable(false);
        tfCodigo.setPreferredSize(new java.awt.Dimension(60, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(15, 0, 5, 5);
        jPanel4.add(tfCodigo, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(15, 0, 5, 15);
        jPanel4.add(tfNome, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        add(jPanel4, gridBagConstraints);

        taDescricao.setColumns(20);
        taDescricao.setRows(5);
        jScrollPane1.setViewportView(taDescricao);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 15, 15);
        add(jScrollPane1, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea taDescricao;
    private javax.swing.JTextField tfCodigo;
    private javax.swing.JTextField tfNome;
    // End of variables declaration//GEN-END:variables
}
